<style lang="scss" scoped>
	.content {
		width: 100%;
		background-color: white;
		padding: 30rpx 0;
	}

	.list {
		padding: 25rpx;
		border-bottom: 1px solid #ccc;
		align-items: flex-start;
		color: #737373;

		.red {
			transform: translateY(6rpx);
		}

		.textarea {
			width: 460rpx;
			height: 120rpx;
			font-size: 28rpx;
		}

		.mic {
			height: 120rpx;
			width: 80rpx;
			border-left: 1px solid #ccc;
			padding-left: 20rpx;
		}

		.ipt {
			width: 550rpx;
		}

		.uploadfile {
			width: 550rpx;

			.btns {
				width: 100%;

				.btn {
					width: 152rpx;
					height: 64rpx;

					border: 2rpx solid #bfbfbf;
					border-radius: 34rpx;
				}
			}
		}

		.record {
			width: 550rpx;
		}
	}
</style>

<template>
	<view class="content">
		<view class="f34 bold" style="padding:0 30rpx;border-bottom: 1px solid #ccc;padding-bottom: 20rpx;">处理</view>
		<view class="list between-flex f28">
			<view class="align-flex">
				处理过程
			</view>
			<view class="align-flex ">
				<textarea class="textarea" style="width:550rpx;" v-model="remark" maxlength="-1"
					placeholder="请填写处理过程" />
				<!-- <view class="mic center-flex">
					<u-icon name="mic" color="#409EFF" size="48"></u-icon>
				</view> -->
			</view>
		</view>


		<view class="list between-flex f28">
			<view class="align-flex">
				附件
			</view>
			<view class="uploadfile">
				<view class="btns align-flex m-bottom20">
					<view class="btn center-flex c666 " @click="uploadfile" style="margin-right: 40rpx;">上传</view>
					<view class="btn center-flex bgblue cfff" @click="chooseImg">拍照</view>
				</view>
				<view class="p-top10 between-flex" v-for="item,index in enclosure" :key="index">
					<view class="align-flex blue" @click="$open(item.url)">
						<u-icon name="file-text" color="#409EFF" size="38"></u-icon>
						{{item.fileName.substring(item.fileName.length-10)}}
					</view>
					<u-icon @click="delfile(index)" name="close" color="#666666" size="30"></u-icon>
				</view>
			</view>
		</view>
		<view class="list between-flex f28">
			<view class="align-flex">
				处理时间
			</view>
			<view class="align-flex " style="width: 550rpx;">
				{{date}}
			</view>
		</view>
		<view class="list between-flex f28">
			<view class="align-flex">
				处理人
			</view>
			<view class="align-flex " style="width: 550rpx;">
				{{username}}
			</view>
		</view>
		<view @click="submit " class="lbtn">确认</view>
	</view>
</template>

<script>
	export default {
		props: {
			orderNum: {
				default: ''
			}
		},
		data() {
			return {
				head: this.$head,
				date: '',
				username: '',
				remark: '',
				enclosure: []
			}
		},
		created() {
			this.date = this.$getDate()
			this.username = uni.getStorageSync('username')
		
		},
		methods: {
			delfile(index) {
				this.enclosure.splice(index, 1)
			},
			//选择图片
			async chooseImg() {

				var file = await this.$chooseImg()

				this.enclosure.push(file)

			},
			async uploadfile() {

				var file = await this.$uploadfile()
				this.enclosure.push(file)

			},
			submit() {

				if (!this.remark) {
					this.$msg('请输入处理过程')
					return
				}
				uni.showLoading({
					title: '提交中...'
				})
				var obj = {
					orderNum: this.orderNum,
					remark: this.remark
				}
				if (this.enclosure.length > 0) {
					var enclosure = []
					this.enclosure.forEach(item => {
						enclosure.push({
							name: item.oldName,
							url: item.url
						})
					})
					obj['processEnclosure'] = JSON.stringify(enclosure)
				}
				this.$pop.ajaxPost('/wechat/order/makeing', obj).then(res => {
					uni.hideLoading()
					if (res.code == 0) {
						this.$msg('提交成功')
						this.$emit('submit')
					} else {
						this.$msg(res.msg)
					}
				})
			},

		}
	}
</script>
